package com.weixing.mall.base.wrapper;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * 通用请求返回封装Bean
 *
 * @author siashan
 * @since  v1.0
 */
@Accessors(chain = true)
@NoArgsConstructor
@Data
@ToString
public class Result<T> {
    /**
     * 状态码
     */
    private int code;
    /**
     * 子状态码
     */
    private int subCode;
    /**
     * 返回描述信息
     */
    private String msg;
    /**
     * 返回数据
     */
    private T data;

    public Result(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(int code, int subCode, String msg) {
        this.code = code;
        this.subCode = subCode;
        this.msg = msg;
    }

    @JsonIgnore
    public boolean isSuccess(){
        return 200 == this.code;
    }
}
